#include "mydialog.h"
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>

MyDialog::MyDialog(QWidget* parent)
    :QDialog(parent)
{
    QVBoxLayout* layout = new QVBoxLayout(this);
    //向对话框中添加内容
    QLabel* label = new QLabel("这是一个对话框",this);
    label->setAlignment(Qt::AlignCenter);
    QPushButton* pushButton = new QPushButton("关闭",this);
    layout->addWidget(label);
    layout->addWidget(pushButton);

    connect(pushButton,&QPushButton::clicked,this,&MyDialog::handle);
}

void MyDialog::handle()
{
    this->close();
}
